package munci.old.learn;

import munci.old.know.words.MetaWord;
import munci.old.know.words.MethodWord;
import munci.old.know.words.Word;
import munci.old.use.Tokens;

public class Control {
	public static final Word[] WORDS =
		MetaWord.all(MethodWord.all(new Word.Book(Control.class))).toArray();

	@MethodWord.Compile("if") public static Tokens if_(Tokens cond, Tokens action) {
		return new Tokens().add("if").add("(").addAll(cond).add(")").addAll(action);
	}

	@MethodWord.Compile("else") public static Tokens else_(Tokens yes, Tokens no) {
		return new Tokens().addAll(yes).add("else").addAll(no);
	}

	@MethodWord.Compile("while") public static Tokens while_(Tokens cond, Tokens action) {
		return new Tokens().add("while").add("(").addAll(cond).add(")").addAll(action);
	}
	
	@MethodWord.Compile("return") public static Tokens return_(Tokens toks) {
		return new Tokens().add("return").addAll(toks);
	}
}
